
package com.punch.common.feign.fallback;


import com.punch.common.dto.login.WXUserDTO;
import com.punch.common.feign.FeignTeacherService;
import com.punch.common.model.LoginUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * userService降级工场
 *
 * @author zlt
 * @date 2019/1/18
 */

@Slf4j
@Component
public class FeignTeacherServiceFallbackFactory implements FallbackFactory<FeignTeacherService> {
    @Override
    public FeignTeacherService create(Throwable throwable) {
        return new FeignTeacherService() {


            /**
             * 根据openId获取小程序登录信息
             *
             * @param openId 小程序openId
             */
            @Override
            public LoginUser getFeignTeacherByOpenId(String openId) {
                log.error("根据openId获取小程序登录信息异常:{}", openId, throwable);
                return new LoginUser();
            }

            /**
             * 根据手机号码获取用户信息
             * @param mobile 手机号码
             */
            @Override
            public LoginUser getFeignTeacherByMobile(String mobile) {
                log.error("根据手机号码获取用户信息信息异常:{}", mobile, throwable);
                return new LoginUser();
            }

            /**
             * 进行注册,不存在则注册,存在则返回
             *
             * @param wxUserDTO 微信用户表单
             */
            @Override
            public boolean saveFeignTeacher(WXUserDTO wxUserDTO) {
                log.error("根据openId与手机号码获取小程序登录信息异常:{}", wxUserDTO, throwable);
                return false;
            }
        };
    }
}

